package xyz.zcq.zcqrpc.protocol;

import lombok.Getter;

/**
 * 协议消息状态 枚举
 */
@Getter
public enum ProtocolMessageStatusEnum {
    OK("ok", 20),
    BAD_REQUEST("badRequest", 40),
    BAD_RESPONSE("badResponse", 50),
    ;

    private final String text;
    private final int value;

    ProtocolMessageStatusEnum(String text, int value) {
        this.text = text;
        this.value = value;
    }

    public static ProtocolMessageStatusEnum getByValue(int value) {
        for (ProtocolMessageStatusEnum pms : ProtocolMessageStatusEnum.values()) {
            if (pms.value == value) {
                return pms;
            }
        }

        return null;
    }

}
